package com.fatcat.easybuy.service.impl;

import com.fatcat.easybuy.exception.BusinessException;
import com.fatcat.easybuy.mapper.EasyBuyOrderDetailMapper;
import com.fatcat.easybuy.pojo.EasyBuyOrderDetail;
import com.fatcat.easybuy.service.EasyBuyOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * @author Fatcat
 * @description 针对表【easybuy_order_detail】的数据库操作Service实现
 * @createDate 2025-09-10 11:04:02
 */
@Service
public class EasyBuyOrderDetailServiceImpl implements EasyBuyOrderDetailService {
    @Autowired
    private EasyBuyOrderDetailMapper easyBuyOrderDetailMapper;

    @Override
    public List<EasyBuyOrderDetail> getOrderDetailByOrderId(Long orderId) {
        return easyBuyOrderDetailMapper.selectOrderDetailByOrderId(orderId);
    }

    @Transactional
    @Override
    public boolean addAllOrderDetail(List<EasyBuyOrderDetail> orderDetailList) {
        try {
            return easyBuyOrderDetailMapper.addAllOrderDetail(orderDetailList) > 0;
        } catch (Exception e) {
            throw new BusinessException("新增订单详情失败", e);
        }
    }
}




